package stream;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Stream;

/**
 * Created by lynn on 2016/6/20.
 */
public class StreamAPI {
    public static void main(String[]args) {
        String cndfDir = "E:/Projects/2016/kbp-edl/res/corpus/2015/eval/source_docs/cmn/discussion_forum/";
        String cnnwDir = "E:/Projects/2016/kbp-edl/res/corpus/2015/eval/source_docs/cmn/newswire/";
        File[] docDirs = {new File(cndfDir), new File(cnnwDir)};

        List<File> dirAll = Arrays.asList(docDirs);

        final int totalDoc = dirAll.stream().reduce(2,(n, d)->{System.out.println(n+"+"+d); return n+d.listFiles().length;}, StreamAPI::sum);
        System.out.println(totalDoc);
    }

    static int sum(int a,int b) {
        System.out.println("sum( "+a+", "+b);
        return a+b;
    }
}
